

export default {
	initToken({state, dispatch}) {
		let token = uni.getStorageSync('token');
		if (token) {
			state.loginStatus = true
			state.token = token
		}
	},
	// 初始化登录状态
	initUser({state, dispatch}) {
		let user = uni.getStorageSync('user');
		if (user) {
			state.user = JSON.parse(user)
			state.loginStatus = true
			state.token = state.user.token
		}
	},
	setUserData({ state, commit }, data) {
		commit('setStateAttr', { key: 'userInfo', val: data })
		uni.setStorageSync('userInfo', data);
	},
	logout2({ state, commit }) {
		commit('setStateAttr', { key: 'userInfo', val: {} })
		uni.removeStorageSync('userInfo');
	}
}